<template>
	<view class="clubAudit">
		<view class="clubList" v-if="clubData.length">
			<ClubAuditItem v-for="(item, index) in clubData" :key="index" :clubId="item.id" :ifAudit="true"
				:clubName="item.clubName" :clubLogo="item.clubLogo" :clubIntro="item.clubIntro"  :head="item.head"
				:headName="item.headName" :headPhone="item.headPhone" :founder="item.founder" :index="index"
				@updateList="updateClubList" />
		</view>
		<view class="noData" v-else>
			<view style="width: 100%; display: flex; justify-content: center">
				<image class="noDataImg" src="@/static/icons/noDataIcon.svg" mode="aspectFill"></image>
			</view>
			<view> 暂无数据 </view>
		</view>
	</view>
</template>

<script setup>
	import {
		ClubAuditItem
	} from "./components/ClubAuditItem.vue"
	import {
		getClubs
	} from '@/apis/apis'
	import {
		ref
	} from 'vue'
	import {
		onShow,
		onReachBottom
	} from '@dcloudio/uni-app'

	const clubData = ref([])
	const page = ref(1)
	const pageSize = ref(3)
	const clubName = ref('')
	const listTotal = ref(999)
	const getClubsList = () => {
		getClubs({
			statu: 0,
			page: page.value,
			pageSize: pageSize.value,
			clubName: clubName.value || ''
		}).then(res => {
			console.log(res, 'xxxxxxxxxxxxxxxxxxxxx')
			clubData.value.push(...res.data)
			listTotal.value = res.total
			page.value++
		})
	}
	const updateClubList = (index) => {
		console.log(index, "数组中的索引");
		// 将数组中的index项删除
		// clubData.value.splice(index, 1)
		page.value = 1;
		clubData.value = []
		getClubsList();
	}

	onShow(() => {
		getClubsList()
	})
	onReachBottom(() => {
		console.log(`触底了`)
		if (listTotal.value > clubData.value.length)
			getClubsList()
	})
</script>
<style scoped>
	page {
		height: 100%;
		background-color: white;

	}
</style>
<style lang="less">
	.clubAudit {
		padding: 40rpx;

		.clubList {
			width: 100%;
			height: 100%;
			display: flex;
			flex-direction: column;
			align-items: center;
		}

		.noData {
			margin-top: 100rpx;
			flex-direction: column;
			align-items: center;
			gap: 20rpx;

			image {
				height: 500rpx;
				width: 500rpx;
			}

			view {
				text-align: center;
				font-size: 45rpx;
			}
		}
	}
</style>